//
//  HJNewFriendsVC.m
//  project
//
//  Created by hu on 2019/4/1.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJNewFriendsVC.h"
#import "HJNewFriendsCell.h"

@interface HJNewFriendsVC ()
@property (nonatomic,strong) NSMutableArray * dataArray;
@end

@implementation HJNewFriendsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navTitle = @"新朋友";
    [self loadNetworkData];
}

-(void)configTableView {
    self.needRefresh = YES;
    self.tableViewStyle = UITableViewStylePlain;
    [super configTableView];
    self.tableView.rowHeight = 90;
    self.tableView.estimatedRowHeight = UITableViewAutomaticDimension;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
}
-(NSMutableArray *)dataArray {
    if (!_dataArray) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}
-(void)loadNetworkData {
    NSString * url =[Api stringByAppendingString:NewFriendNoticeApi];//
    [HJHttpTool post:url params:@{@"userId":[HJUserManager getUserModel].userId,@"pageCurrent":@(self.page)} success:^(HJResponeds *result) {
        self.totalPage = result.data[@"pages"];
        if (self.page == 1) {
            [self.dataArray removeAllObjects];
        }
        NSArray * arr = [NSArray yy_modelArrayWithClass:[HJNewFriendModel class] json:result.data[@"records"]];
        [self.dataArray addObjectsFromArray:arr];
        [self.tableView reloadData];
        [self.tableView endRefresh];
    } failure:^(id result) {
        [self.tableView endRefresh];
        [self showErrorHUDWithError:result];
    }];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    HJNewFriendsCell * friendCell =[tableView cellForRowAtIndexPath:indexPath];
    if (!friendCell) {
        friendCell = [[NSBundle mainBundle]loadNibNamed:@"HJNewFriendsCell" owner:nil options:nil].firstObject;
    }
    [friendCell loadDataModel:self.dataArray[indexPath.row]];
    
    return friendCell;
}

//-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
//    return YES;
//}
//
//-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
//    return UITableViewCellEditingStyleDelete;
//}
//
//-(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
//    UITableViewRowAction * deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
//
//    }];
//    deleteAction.backgroundColor = [UIColor colorWithPatternImage:setImage(@"friendsChat")];
//    return @[deleteAction];
//}

@end


@implementation HJNewFriendModel


@end
